/**
 * 
 */
package base.io;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;

/**
 * @author bliu
 *
 */
public class FileCombine {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		File files = new File("C:/temp/rakuten/2");
		
		//获取写入字符文件的便捷类
		FileWriter fileWriter = new FileWriter("C:/temp/rakuten/rakuten-combine-2.txt");
		//缓冲输出,防止每个字符进行字节转换并迅速写入文件,提高性能
		BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
		
		for (File file : files.listFiles()) {
			if (file.isFile()) {
				FileReader fileReader = new FileReader(file);
				BufferedReader reader = new BufferedReader(fileReader);
				String content = null;
				reader.readLine();
				while ((content = reader.readLine()) != null) {
					bufferedWriter.write(content);
					bufferedWriter.write("\n");
				}
				reader.close();
				fileReader.close();
				bufferedWriter.flush();
			}
		}
		bufferedWriter.close();
		fileWriter.close();
	}

}
